

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cadastro de receita</title>
        <link rel="stylesheet" type="text/css" href="css/css.css">
    </head>
    <body>
        <jsp:useBean id="user" class="Model.Usuario" scope="session"/>
        <jsp:useBean id="receita" class="Model.Receita" scope="session"/>
        <c:choose>     
            <c:when test="${user.getLogin()!=null}">
                <h1>Cadastro de Receita</h1>
                <form id="cad-receita" name="cad-receita" method="POST" action="ServletReceita?opt=insert" onsubmit="valid_cad_receita(this)">
                    <table >
                        <tr>
                            <td><label for="name">Nome da Receita:</label></td>
                            <td>
                                <input id ="name" name="name" value="${receita.getName()}" required><input type="hidden" value="${user.getLogin()}" id="user" name="user">
                                <input type="hidden" id="id" name="id" value="${receita.getId()}"/>
                            </td>
                        </tr> 
                        <tr>
                            <td><label for="categoria">Categoria:</label></td>
                            <td><select id="categoria" name="categoria">
                                    <option value="salgados">Salgados</option>
                                    <option value="doces">Doces</option>
                                    <option value="bebida">Bebida</option>
                                </select>
                            </td>
                        </tr> 
                        <tr>
                            <td><label for="ingredientes" >Ingredientes:</label></td>
                            <td><textarea  name="ingredientes" rows="4" cols="50" required>${receita.getIngredientes()}</textarea></td>
                        </tr> 
                        <tr>
                            <td><label for="val-nutri">Valor nutricional:</label></td>
                            <td><input id="val-nutri" name="val-nutri" type="number" min="0" max="9999" step="1" value="${receita.getVal_nutri()}" required></td>
                        </tr> 
                        <tr>
                            <td><label for="clue">Dicas</label></td>
                            <td><textarea id="clue" name="clue" rows="4" cols="50" >${receita.getClue()}</textarea></td>
                        </tr> 
                        <tr>
                            <td><label for="val-nutri">Tempo de preparo (Minutos) </label></td>
                            <td><input id="time" name="time" type="number" min="0" max="9999" step="0.5" value="${receita.getTime()}" required></td>
                        </tr> 
                        <tr>
                            <td><label for="name">Status</label></td>
                            <td> <select id="status" name="status">
                                    <option value="no">Indisponível</option>
                                    <option value="yes" selected >Disponivel</option>
                                </select>
                            </td>
                        </tr> 
                        <tr>
                            <td><label for="avg">Média de notas</label></td>
                            <td><select id="avg" name="avg">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>

                            </td>
                            <td>
                                <input type="submit" value="Enviar"><br/>
                                <br><a href="ServletUsuario?opt=detalhes" style="margin-left: 300px;">Voltar</a>
                            </td>
                        </tr>
                    </table>
                </form>
            </c:when>
            <c:otherwise>
                <h1> Usuário Não Cadastrado </h1>
            </c:otherwise>
        </c:choose>
    </body>
</html>
